<?php
if ($using_dollar_currency == 1) {
    $crc_text = "$ ";
} else {
    $crc_text = "Rp. ";
}
?>

<table>
    <tr>
        <td width="15%">&nbsp;</td>
        <td width="1%">&nbsp;</td>
        <td width="30%">&nbsp;</td>
        <td width="8%">&nbsp;</td>
        <td width="15%">&nbsp;</td>
        <td width="1%">&nbsp;</td>
        <td width="30%">&nbsp;</td>
    </tr>
    <tr>
        <td colspan="7" align="center">QUOTATION</td>
    </tr>
    <tr>
        <td colspan="7" align="center">&nbsp;<br/>&nbsp;</td>
    </tr>
    <tr>
        <td>To</td>
        <td>:</td>
        <td><span><?php echo $nama_customer; ?></span></td>
        <td>&nbsp;&nbsp;&nbsp;</td>
        <td>Date</td>
        <td>:</td>
        <td><span><?php echo $tanggal_quotation; ?></span></td>
    </tr>
    <tr>
        <td>Detail Address</td>
        <td>:</td>
        <td><span><?php echo $alamat_detail_customer; ?></span></td>
        <td>&nbsp;&nbsp;&nbsp;</td>
        <td>RF No.</td>
        <td>:</td>
        <td><span><?php echo $rf_number; ?></span></td> 
    </tr>
    <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td><span><?php echo $alamat_komplit; ?></span></td>
        <td>&nbsp;&nbsp;&nbsp;</td>
        <td>QF ASP NO</td>
        <td>:</td>
        <td><span><?php echo $nomor_quotation; ?></span></td>
    </tr>
    <tr>
        <td>Phone</td>
        <td>:</td>
        <td><span><?php
$ktk_kmplt = explode("/", $kontak_komplit);
$ktk_kmplt[1] .= " (Fax)";
$ktk_kmplt[2] .= " (Mail)";
echo implode("<br/>", $ktk_kmplt);
?></span></td>
        <td>&nbsp;&nbsp;&nbsp;</td>
        <td>Vessel</td>
        <td>:</td>
        <td><span><?php echo $nama_vessel; ?></span></td>
    </tr>
    <tr>
        <td>Attendance</td>
        <td>:</td>
        <td><span><?php echo $attendance; ?></span></td>
        <td>&nbsp;&nbsp;&nbsp;</td>
        <td>Port</td>
        <td>:</td>
        <td><span><?php echo $nama_port; ?></span></td>
    </tr>
    <tr>
        &nbsp;&nbsp;&nbsp;
    </tr>
    <tr>
        <td>Subject</td>
        <td>:</td>
        <td colspan="6" align="left"><span><?php echo $subject; ?></span></td>   
    </tr>

    <tr>
        <td colspan="7">
            <br/><br/><br/>

            <table border="1" cellpadding="8px" style="width: 100%;">
                <thead>
                    <tr class="GridHeader">
                        <td align="center" width="8%">No.</td>
                        <td align="center" width="40%">Description</td>
                        <td align="center" width="15%">Qty</td>
                        <td align="center">Unit Price</td>
                        <td align="center">Total Price</td>
                    </tr>
                </thead>
                <tbody id="tablebody">
                    <?php
                    if ($item->num_rows() > 0) {
                        $nomor = 1;
                        $total_harga = 0;
                        foreach ($item->result() as $row) {
                            if ($using_dollar_currency == 1) {
                                $crc_nom = $row->harga_jual_dollar;
                            } else {
                                $crc_nom = $row->harga_jual;
                            }
                            $total = $crc_nom * $row->quantity;
                            ?>
                            <tr>
                                <td align="center"><?php echo $nomor++; ?></td>
                                <td><?php echo $row->nama_item ?></td>
                                <td align="center"><?php echo $row->quantity . " " . $row->satuan_beli ?></td>
                                <td align="right"><span style="float: left;"><?php echo $crc_text ?></span><?php echo number_format($crc_nom, 0, ",", ".") ?></td>
                                <td align="right"><span style="float: left;"><?php echo $crc_text ?></span><?php echo number_format($total, 0, ",", ".") ?></td>
                            </tr>
                            <?php
                            $total_harga += $total;
                        }
                    } else {
                        ?>
                        <tr>
                            <td colspan="5" align="center">Tidak ada data</td>
                        </tr>
                    <?php } ?>
                </tbody>
                <tfoot>
                    <tr class="GridHeader">
                        <td colspan="4" align="right">Total</td>
                        <td align="right"><span style="float: left;"><?php echo $crc_text ?></span><?php echo number_format($total_harga, 0, ",", ".") ?></td>
                    </tr>
                    <?php
                    if ($using_ppn) {
                        $ppn = $total_harga * 0.012;
                        $grand_total = $total_harga + $ppn;
                        ?>
                        <tr class="GridHeader">
                            <td colspan="4" align="right">PPH (1.2%)</td>
                            <td align="right"><span style="float: left;"><?php echo $crc_text ?></span><?php echo number_format($ppn, 0, ",", "."); ?></td>
                        </tr>
                        <tr class="GridHeader">
                            <td colspan="4" align="right">Grand Total</td>
                            <td align="right"><span style="float: left;"><?php echo $crc_text ?></span><?php echo number_format($grand_total, 0, ",", "."); ?></td>
                        </tr>
                    <?php }
                    else
                        $grand_total = $total;
                    ?>
                </tfoot>
            </table> 
            <br/>
        </td>
    </tr>  
    <tr> 
        <td><?php
            if ($crc == "$")
                echo "Said";
            else
                echo "Terbilang";
            ?>
        </td>
        <td>:</td>
        <td colspan="5">
            <?php
            if ($crc == "$")
                echo ucwords(said($grand_total)) . " Dollars";
            else
                echo ucwords(terbilang($grand_total)) . " Rupiah";
            ?>
        </td>
    </tr>
    <tr>    
        <td colspan="3" align="center">Quote By</td>
        <td>&nbsp;</td>
        <td colspan="3" align="center">Approved By</td>
    </tr> 
    <tr> 
        <td colspan="7" align="center">&nbsp;<br/>&nbsp;<br/>&nbsp;<br/>&nbsp;<br/>&nbsp;<br/>&nbsp;<br/>&nbsp;</td>
    </tr>
    <tr> 
        <td colspan="3" align="center">(<?php echo $quote_by ?>)</td>
        <td>&nbsp;</td>
        <td colspan="3" align="center">(<?php echo $approved_by ?>)</td>
    </tr>
</table>